<?php

use yii\helpers\Url;

$this->title = '消费记录';
?>
<header>
    <div class="consumHis">
    <header class="header">
    <a href="javascript:void(0);" onclick="javascript:history.go(-1);return false;">
        <i class="back-icon"></i>
    </a>消费记录
</header>
        <div class="page-bd">
            <!-- 加载方式需要和PHP商议
            <div class="weui-loadmore">
                <i class="weui-loading"></i>
                <span class="weui-loadmore__tips">正在加载</span>
            </div> -->
            <ul id='couponsList'>
                <?php foreach ($transactions as $trans) { ?>
                 <li class="">
                    <div class="weui-flex js-category">
                        <div class="weui-flex-item">
                            <div class="weui_panel">
                                <div class="weui_panel_bd">
                                    <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg consume_a" >
                                        <div class="weui_media_bd">
                                            <h4 class="weui_media_title hisTitle">
                                                <!-- ****************************************** -->
                                                流水号:<span><?=$trans['serialNo']?></span>
                                            </h4>
                                            <h4 class="weui_media_title hisTitle">
                                                <!-- ****************************************** -->
                                                <?=$trans['store']?>
                                            </h4>
                                        </div>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <i class="icon icon-74"></i>
                    </div>
                    
                    <div class="page-category js-categoryInner consume_showcontent">

                        <div class="weui_cells consume_list">
                            <div class="weui_cell lcontent_header" >
                                <!-- ************************************************************** -->
                                <div class="weui-flex-item consum_left">
                                    <p>消费时间</p>
                                    <p><?=date_format(date_create($trans['date']), 'Y-m-d')?></p>
                                </div>
                                <div class="weui-flex-item">
                                    <p>消费金额</p>
                                    <p><?php 
                                          $amount = array_map(function($v1, $v2){ return $v1*$v2;}, array_column($trans['goods'], 'price'), array_column($trans['goods'], 'quantity'));
                                          echo array_sum($amount);
                                    ?></p>
                                    
                                </div>
                                <div class="weui-flex-item consum_right" >
                                    <p>消费积分</p>
                                    <p><?php 
                                    $amount = array_map(function($v1, $v2){ return $v1*$v2;}, array_column($trans['goods'], 'points'), array_column($trans['goods'], 'quantity'));
                                          echo array_sum($amount);
                                    ?></p>
                                </div>
                            </div>

                          
                            <?php foreach ($trans['goods'] as $v) { ?>
                            
                            <div class="weui_cell lcontent_cell">
                                <div class="consum_left">
                                    <p>《<?=$v['book']?>》</p>
                                </div>
                                <div >
                                    <p>x<span><?=$v['quantity']?></span></p>
                                </div>
                                <div >
                                    <p>&yen;<span><?=number_format($v['price'],2)?></span></p>
                                </div>
                                <div class="consum_right">
                                    <p>正常消费</p>
                                </div>
                            </div>
                            <?php } ?>
                        </div>
                    </div>
                </li>       
                <?php }?>               
               
            </ul>
        </div>
    </div>  

